import { COLUMNS_WIDTH } from '@/utils/common'
import { formatTime } from '@/utils/format'

import { channelMaps, productTypeMaps } from './constant'

export const COLUMNS = [
    {
        title: '#',
        dataIndex: 'id',
        key: 'id',
        width: COLUMNS_WIDTH.id
    },
    {
        title: '农产品名',
        dataIndex: 'name',
        key: 'name',
        width: COLUMNS_WIDTH.wd1
    },
    {
        title: '销量(万)',
        dataIndex: 'sales',
        width: COLUMNS_WIDTH.wd1,
        key: 'sales'
    },
    {
        title: '销售渠道',
        dataIndex: 'salesChannel',
        width: COLUMNS_WIDTH.wd1,
        key: 'salesChannel',
        customRender: ({ value }: any) => {
            return channelMaps[value]
        }
    },
    {
        title: '产品类别',
        dataIndex: 'productType',
        width: COLUMNS_WIDTH.wd1,
        key: 'productType',
        customRender: ({ value }: any) => {
            return productTypeMaps[value]
        }
    },
    {
        title: '回购量(万)',
        dataIndex: 'repurchaseCounts',
        width: COLUMNS_WIDTH.wd1,
        key: 'repurchaseCounts'
    },
    {
        title: '产量(吨)',
        dataIndex: 'products',
        width: COLUMNS_WIDTH.wd1,
        key: 'products'
    },
    {
        title: '出货量(吨)',
        dataIndex: 'outProducts',
        width: COLUMNS_WIDTH.wd1,
        key: 'outProducts'
    },
    {
        title: '库存量(吨)',
        dataIndex: 'stock',
        width: COLUMNS_WIDTH.wd1,
        key: 'stock'
    },
    {
        title: '今日价格(元/斤)',
        dataIndex: 'todayPrice',
        width: COLUMNS_WIDTH.wd1,
        key: 'todayPrice'
    },
    {
        title: '昨日价格(元/斤)',
        dataIndex: 'yestodayPrice',
        width: COLUMNS_WIDTH.wd1,
        key: 'yestodayPrice'
    },
    {
        title: '未来价格预测(元/斤)',
        dataIndex: 'futurePrice',
        width: COLUMNS_WIDTH.wd1,
        key: 'futurePrice'
    },
    {
        title: '创建时间',
        dataIndex: 'createdTime',
        key: 'createdTime',
        width: COLUMNS_WIDTH.wdDate,
        customRender: (value: any) => {
            return formatTime(value.text, 'YYYY-MM-DD HH:mm:ss')
        }
    },
    {
        title: '更新时间',
        dataIndex: 'updatedTime',
        key: 'updatedTime',
        width: COLUMNS_WIDTH.wdDate,
        customRender: (value: any) => {
            return formatTime(value.text, 'YYYY-MM-DD HH:mm:ss')
        }
    },
    {
        title: '操作',
        dataIndex: 'action',
        key: 'action',
        width: COLUMNS_WIDTH.wdBtn,
        fixed: 'right'
    }
]
